package com.anXin.article.controller;

import com.anXin.article.service.ArticlePublishService;
import com.anXin.article.service.ArticleService;
import com.anXin.model.article.dtos.ArticleDto;
import com.anXin.model.article.dtos.ArticlePublishDto;
import com.anXin.model.common.dtos.ResponseResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


@RestController
@RequestMapping("/api/v1/news")
public class ArticlePublishController {

    @Autowired
    private ArticlePublishService articlePublishService;
    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile){
        return articlePublishService.uploadPicture(multipartFile);
    }


    @PostMapping("/submit")
    public ResponseResult submitNews(@RequestBody ArticlePublishDto dto){
        return articlePublishService.submitNews(dto);
    }

    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody ArticlePublishDto dto){
        return articlePublishService.downOrUp(dto);
    }
}
